package com.shrct.businessprocess.purchase.impl;

import com.shrct.businessprocess.budget.RCCostBreakDown;
import com.shrct.businessprocess.project.RCExchangeRate;
import com.shrct.businessprocess.project.RCProject;
import com.shrct.businessprocess.purchase.RCBaseProductPurchaseBudget;
import com.shrct.businessprocess.purchase.RCTransferCostTransaction;
import com.shrct.businessprocess.purchase.RCTransforCostPayRequest;
import com.shrct.businessprocess.purchase.impl.RCBaseProductPurchaseBudgetImpl;
import com.shrct.businessprocess.purchase.impl.RCPayRequestImpl;
import com.shrct.businessprocess.purchase.impl.RCTransferCostTransactionImpl;
import com.shrct.businessprocess.purchase.proxy.RCTransforCostPayRequestProxy;
import edu.fudan.mylang.pf.IObjectFactory;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;

@Entity
@DiscriminatorValue("RCTRANSFORCOSTPAYREQUEST_TYPE")
public class RCTransforCostPayRequestImpl extends RCPayRequestImpl implements RCTransforCostPayRequest {
  public RCTransforCostPayRequestImpl() {
    super();
  }
  
  public RCTransforCostPayRequestImpl(final RCBaseProductPurchaseBudget budget) {
    super();
    this.budget = budget;
  }
  
  @JoinColumn(name = "transaction_id")
  @ManyToOne(targetEntity = RCTransferCostTransactionImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCTransferCostTransaction transaction;
  
  public RCTransferCostTransaction getTransaction() {
    return this.transaction;
  }
  
  public RCTransforCostPayRequest setTransaction(final RCTransferCostTransaction transaction) {
    this.transaction = transaction;
    return this;			
    
  }
  
  @JoinColumn(name = "budget_id")
  @ManyToOne(targetEntity = RCBaseProductPurchaseBudgetImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCBaseProductPurchaseBudget budget;
  
  public RCBaseProductPurchaseBudget getBudget() {
    return this.budget;
  }
  
  public RCTransforCostPayRequest setBudget(final RCBaseProductPurchaseBudget budget) {
    this.budget = budget;
    return this;			
    
  }
  
  public RCExchangeRate getDefaultExchangeRate() {
    RCBaseProductPurchaseBudget _budget = this.getBudget();
    RCCostBreakDown _cbd = _budget.getCbd();
    RCProject _project = _cbd.getProject();
    RCExchangeRate _defaultExchangeRate = _project.getDefaultExchangeRate();
    return _defaultExchangeRate;
  }
  
  public String getEntityName() {
    return "\u8D39\u7528\u644A\u6D88";
  }
  
  public static RCTransforCostPayRequest create(final RCBaseProductPurchaseBudget budget, final IObjectFactory objectFactory) {
    com.shrct.businessprocess.purchase.RCTransforCostPayRequest rCTransforCostPayRequest = new com.shrct.businessprocess.purchase.impl.RCTransforCostPayRequestImpl(
    	budget
    );
    objectFactory.create(rCTransforCostPayRequest);
    return rCTransforCostPayRequest;			
    
  }
  
  public static RCTransforCostPayRequest createRCTransforCostPayRequestImpl(final RCBaseProductPurchaseBudget budget, final IObjectFactory objectFactory, final Procedure1<RCTransforCostPayRequest> init) {
    com.shrct.businessprocess.purchase.RCTransforCostPayRequest rCTransforCostPayRequest = new com.shrct.businessprocess.purchase.impl.RCTransforCostPayRequestImpl(
    	budget
    );
    objectFactory.create(rCTransforCostPayRequest);
    init.apply(rCTransforCostPayRequest);
    
    return rCTransforCostPayRequest;			
    
  }
  
  public RCTransforCostPayRequestProxy toProxy() {
    com.shrct.businessprocess.purchase.proxy.RCTransforCostPayRequestProxy proxy = new com.shrct.businessprocess.purchase.proxy.RCTransforCostPayRequestProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
